/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package OilSimNoteBook;

import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;

/**
 *
 * @author anthony
 */
public class LoginPane extends OilSimUIComponent implements ActionListener{
    public static final String LOGIN_CLICKED = "LOGIN_CLICKED";
    public static final String REGISTER_CLICKED = "REGISTER_CLICKED";
    private JPanel mainPanel, loginPanel, registerPanel;
    JButton registerButton, loginButton;
    JLabel  loginUserName, loginPassword, regUserName, regPassword, regPasswordConfirm;
    JTextField loginUserNameTF, loginPasswordTF, regPasswordTF, regPasswordConfirmTF, regUserNameTF;
    BoxLayout layout;

    public LoginPane() {
        mainPanel = new JPanel();
        layout = new BoxLayout(mainPanel, BoxLayout.LINE_AXIS);
        
        loginPanel = new JPanel();
        loginPanel.setBorder(new TitledBorder("Login"));
        
        GridLayout loginLayout = new GridLayout(3, 2);
        loginPanel.setLayout(loginLayout);
        loginUserName = new JLabel("User name:");
        loginPassword = new JLabel("Password: ");
        loginPasswordTF = new JTextField();
        loginUserNameTF = new JTextField();
        loginButton = new JButton("Login");
        loginButton.addActionListener(this);
        
        loginPanel.add(loginUserName);
        loginPanel.add(loginUserNameTF);
        loginPanel.add(loginPassword);
        loginPanel.add(loginPasswordTF);
        loginPanel.add(loginButton);
        
        registerPanel = new JPanel(new GridLayout(4, 2));
        registerPanel.setBorder(new TitledBorder("Register"));
        
        regUserName = new JLabel("User name:");
        regUserNameTF = new JTextField();
        regPassword = new JLabel("Password:");
        regPasswordTF = new JTextField();
        regPasswordConfirm = new JLabel("Password Confirm:");
        regPasswordConfirmTF = new JTextField();
        registerButton = new JButton("Register");
        
        registerPanel.add(regUserName);
        registerPanel.add(regUserNameTF);
        registerPanel.add(regUserNameTF);
        registerPanel.add(regPassword);
        registerPanel.add(regPasswordTF);
        registerPanel.add(regPasswordConfirm);
        registerPanel.add(regPasswordConfirmTF);
        registerPanel.add(registerButton);
        
        
        
        mainPanel.add(loginPanel);
        mainPanel.add(registerPanel);
    }
    
    
    
    @Override
    public Container getPanel() {
        return mainPanel;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if(e.getActionCommand().equals(loginButton.getActionCommand())){
            setChanged();
            notifyObservers(LOGIN_CLICKED);
        }
    }
    
    public static void main(String[] args) {
        new LoginPane().showFrame();
    }
    
}
